﻿using System.Windows;
using System.Windows.Input;
using RG.Common;

namespace RG.Common.WPF.Filters
{
    /// <summary>
    /// Interaction logic for FiltersFrame.xaml
    /// </summary>
    public partial class FiltersFrame: IView<FiltersFrameVM>
    {
        public FiltersFrame()
        {
            InitializeComponent();
        }

        #region Implementation of IView<FiltersFrameVM>

        public FiltersFrameVM Presenter
        {
            get { return (FiltersFrameVM) DataContext; }
            set { DataContext = value; }
        }

        #endregion

        private void Del_OnExecute(object sender, ExecutedRoutedEventArgs e)
        {
            if (sender is FiltersFrame)
            {
                var fFrame = (FiltersFrame) sender;
                var flt = fFrame.Presenter.Filter[fFrame.Presenter.SelectedIndex];
                if (flt.ValueEmpty()) return;
            }
            if (MessageBox.Show("Очистить фильтр?", "Сообщение.", MessageBoxButton.OKCancel, 
                MessageBoxImage.Question, MessageBoxResult.Cancel) != MessageBoxResult.OK) return;
            Presenter.ClearCurrentFilter();
            e.Handled = true;
        }

    }
}
